Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 26, 2025

Problem

When multiple dialogs were stacked (nested dialogs), the second and subsequent dialogs could not scroll properly when their content exceeded the viewport height. Users could scroll the first dialog normally, but any additional dialogs opened on top would have their scrolling functionality broken.

Root Cause

The CSS rule .modal-multiple .modal-dialog used position: fixed with inset: 0, which made nested dialogs fill the entire viewport and overrode Bootstrap's normal modal scrolling behavior. This prevented the standard Bootstrap modal scrolling mechanism from functioning correctly.

Solution

Enhanced the CSS for multiple dialogs to maintain proper modal behavior while preserving the stacking functionality:

.modal-multiple .modal-dialog {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--bs-modal-margin, 0.5rem);

    // Ensure scrolling works for multiple dialogs
    .modal-content {
        max-height: calc(100vh - var(--bs-modal-margin, 0.5rem) * 2);
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .modal-body {
        overflow-y: auto;
        flex: 1 1 auto;
    }
}

The fix:

  1. Maintains proper centering using flexbox layout
  2. Preserves modal spacing with Bootstrap's modal margins
  3. Controls content height to fit within viewport constraints
  4. Enables scrolling in the modal body while keeping headers/footers fixed

Testing

  • All existing unit tests pass (27/27 dialog/modal tests)
  • Created comprehensive test page demonstrating the fix
  • Verified nested dialogs now scroll properly at any depth
  • No breaking changes to existing modal functionality

Before/After

Before: Nested dialogs filled entire viewport, no scrolling possible
After: Nested dialogs properly centered and scrollable, maintaining Bootstrap modal behavior

Original prompt

This section details on the original issue you should resolve

<issue_title>bug(Dialog): Dialog多级弹窗滚动异常</issue_title>
<issue_description>### Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

当多级弹窗都超过屏幕大小时,第二层弹窗开始无法滚动。

Expected Behavior

多级弹窗可以正常滚动

Interactive render mode

Interactive Server (Interactive server-side rendering (interactive SSR) using Blazor Server)

Steps To Reproduce

BootstrapBlazorApp4.zip
点击首页的点我按钮,弹出弹窗,滚动到最下方,然后在弹窗的下方还有一个点我按钮,再次点击点我按钮,新弹出的弹窗无法滚动。

Exceptions (if any)

.NET Version

NET9.0

Anything else?

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #6748

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@bb-auto
Copy link

bb-auto bot commented Sep 26, 2025

Thanks for your PR, @Copilot. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copilot AI changed the title [WIP] bug(Dialog): Dialog多级弹窗滚动异常 fix(Dialog): Fix scrolling issue in nested/multiple dialogs Sep 26, 2025
Copilot AI requested a review from ArgoZhang September 26, 2025 04:22
Copilot finished work on behalf of ArgoZhang September 26, 2025 04:22
@ArgoZhang ArgoZhang marked this pull request as ready for review September 27, 2025 01:23
Copilot AI review requested due to automatic review settings September 27, 2025 01:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a scrolling issue in nested/multiple dialogs where the second and subsequent dialogs could not scroll properly when their content exceeded the viewport height. The fix enhances the CSS for multiple dialogs to maintain proper modal behavior while preserving the stacking functionality.

  • Adds flexbox layout to center dialogs properly
  • Controls content height with viewport constraints and enables scrolling in the modal body
  • Creates a comprehensive test page to verify the fix works at any nesting depth

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/BootstrapBlazor/Components/Modal/Modal.razor.scss Enhanced CSS rules for .modal-multiple .modal-dialog to fix scrolling behavior while maintaining proper centering and spacing
src/BootstrapBlazor.Server/Components/Pages/TestScrollDialog.razor Added comprehensive test page demonstrating nested dialog scrolling functionality with three levels of dialogs

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Sep 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7051bf1) to head (865719b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #6786   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          739       739           
  Lines        31739     31744    +5     
  Branches      4467      4468    +1     
=========================================
+ Hits         31739     31744    +5     
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ArgoZhang ArgoZhang merged commit d451a73 into main Sep 27, 2025
7 checks passed
@ArgoZhang ArgoZhang deleted the copilot/fix-030e1e49-e9e3-4284-bfb2-1455f503ce53 branch September 27, 2025 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(Dialog): Dialog多级弹窗滚动异常

2 participants